﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using SharepointSolutionInstaller.Resources;
using SharepointSolutionInstaller.Utils.Configuration;

namespace SharepointSolutionInstaller.Utils.RequiredChecks
{
    internal class SolutionFileCheck : SystemCheck
    {

        string filename;
        public static SystemCheckResult systemCheckResult;
        internal SolutionFileCheck(string solutionFileName)
            : base("SolutionFileCheck")
        {
            this.filename = solutionFileName;
        }

        protected override SystemCheckResult DoExecute()
        {

            if (!String.IsNullOrEmpty(filename))
            {
                FileInfo solutionFileInfo = new FileInfo(filename);
                if (!solutionFileInfo.Exists)
                {
                    if (filename == InstallConfiguration.OfficeSolutionFile)
                        return SystemCheckResult.OfficeError;
                    throw new Exception(string.Format(CommonUIStrings.installExceptionFileNotFound, filename));

                }
            }
            else
            {
                throw new Exception(CommonUIStrings.installExceptionConfigurationNoWsp);
            }
            return SystemCheckResult.Success;
        }
    }
}